<?php

namespace App\Console\Commands;

use App\Jobs\ExploreRefundJob;
use App\Mail\SendEmail;
use App\Models\Activity;
use App\Models\Common\Wechat;
use App\Models\ProxyMember;
use App\Models\Shop;
use App\Models\Tools\Data;
use App\Models\Tools\Message;
use EasyWeChat\Kernel\Messages\Text;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;

class Testing extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:testing';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '开发环境测试脚本';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        try {
//            $app = Wechat::officialAccount();
//            $list = $app->material->list('news', 0, 10);
//            dump($list);
//            return true;

            $app = Wechat::officialAccount();
            $app->customer_service->message('111')->to('o9cRLwBJOdcU_rkBz5qIRY4Mtq4k')->send();

//            $result = ProxyMember::qrCode(1);
//            dump($result);

//            Mail::to('18617522755@163.com')->send(new SendEmail());

//            $this->info(encrypt(159));
//
//            $this->info('success');

//            $app = Wechat::officialAccount();
//            $result = $app->qrcode->temporary('http://www.baidu.com');
//            dump($result);
//            $url = $app->qrcode->url($result['ticket']);
//            dump($url);

//            $message = $this->ask('message');

//            $openid = $this->ask('openid');
//            $app = Wechat::officialAccount();
//            $message = '有新的霸王餐发布，快来参与噢~<a href=" '.env('APP_LAIFEI_URL').'/lottery">👉点此参与</a>';
//            $message = new Text($message);
//            $result = $app->customer_service->message($message)->to($openid)->send();
//            dump($result);

            return true;
        } catch (\Exception $e) {
            print_r(['msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
            return false;
        }
    }
}
